<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateGoodsCommentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('goods_comments', function (Blueprint $table) {
            $table->id();
            $table->integer('gid')->default(0)->comment('商品ID');
            $table->integer('oid')->default(0)->comment('订单ID');
            $table->integer('mid')->default(0)->comment('会员ID');
            $table->integer('sid')->default(0)->comment('商店ID');
            $table->float('score')->default(5)->comment('评分');
            $table->string('content', 256)->default('')->comment('内容');
            $table->text('images')->comment('图片');
            $table->tinyInteger('has_image')->comment('是否有图评论 1 是 0 否');
            $table->timestamps();
            $table->index('gid');
            $table->index('oid');
            $table->index('mid');
            $table->index('sid');
            $table->index('score');
            $table->index('has_image');
        });
        DB::statement("ALTER TABLE `goods_comments` comment '商品评论表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('goods_comments');
    }
}
